using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Styling;
using AvaloniaApplication1.ViewModels;

namespace AvaloniaApplication1.Views;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void AddManyClick(object? sender, RoutedEventArgs e)
    {
        for (int i = 0; i < 10; i++)
        {
            this.Panel.Children.Add(new Button(){Content = $"{i}"});
        }
    }

    private void RemoveManyClick(object? sender, RoutedEventArgs e)
    {
        this.Panel.Children.Clear();
        GC.Collect();
    }

    private void AddFluentThemeButton(object? sender, RoutedEventArgs e)
    {
        var found2 = this.TryFindResource("FluentButton", this.ActualThemeVariant, out var result2);
        for (int i = 0; i < 10; i++)
        {
            this.Panel.Children.Add(new Button(){Theme = (ControlTheme?)result2,Content = $"{i}"});
        }
    }

    private void AddFluentSimpleButton(object? sender, RoutedEventArgs e)
    {
        var found2 = this.TryFindResource("FluentThemeSimpleColor", this.ActualThemeVariant, out var result2);
        for (int i = 0; i < 10; i++)
        {
            this.Panel.Children.Add(new Button(){Theme = (ControlTheme?)result2,Content = $"{i}"});
        }
    }

    private void AddFluentRedButton(object? sender, RoutedEventArgs e)
    {
        var found2 = this.TryFindResource("FluentThemeRedColor", this.ActualThemeVariant, out var result2);
        for (int i = 0; i < 10; i++)
        {
            this.Panel.Children.Add(new Button(){Theme = (ControlTheme?)result2,Content = $"{i}"});
        }
    }

    private void AddSimpleThemeButton(object? sender, RoutedEventArgs e)
    {
        var found2 = this.TryFindResource("SimpleTheme", this.ActualThemeVariant, out var result2);
        for (int i = 0; i < 10; i++)
        {
            this.Panel.Children.Add(new Button(){Theme = (ControlTheme?)result2,Content = $"{i}"});
        }
    }

    private void ShowMenu(object? sender, RoutedEventArgs e)
    {
        var btn = sender as Button;
        var vm = DataContext as MainWindowViewModel;
        vm.ChangeMenus();
        btn.ContextMenu.Open(btn);
    }
}